package com.vortex.cloud.zhsw.xinyang.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author gyl
 * @version 1.0
 * @date 2023/2/9 15:14
 */

public class CodeGenUtils {

    /**
     * 生成编码
     * @param count 数量
     * @param digit 位数
     * @param pre 前缀
     * @return
     */
    public static String getCode(Integer count,Integer digit,String pre){
        String format = String.format("%0" + digit + "d", count+1);
        String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        return new StringBuffer(pre).append(date).append(format).toString();
    }
}
